/*
* (c) 2014 University of Applied Sciences, Karlsruhe
* Project "Segmentation of depth data of a plenoptic camera"
* summer semester 2014
*
* fit_line_3d_minimum_variance.h
* This file contains the implementation of the minimum variance line fitting algorithm.
*/


#ifndef _FIT_LINE_3D_MINIMUM_VARIANCE_H_
#define _FIT_LINE_3D_MINIMUM_VARIANCE_H_

#include "sgBase/geometrics/line_3d.h"
#include "sgMain/3d/fit_line_3d.h"

using namespace sgBase;

namespace sgMain
{
	/** 
	Class to fit a 2D contour in 3D point cloud using a combination of data averaging and a minimum variance linear estimator.
	*/
	class FitLine3DMinimumVariance : public FitLine3D
	{
	protected:
		int FitMinimumVariance();
	public:
		FitLine3DMinimumVariance(const Line3D &line2D, const pcl::PointCloud<pcl::PointXYZRGB>::Ptr &depthCloud, const cv::Mat &intrinsicParameters, double radius);
		virtual ~FitLine3DMinimumVariance();
		virtual int FitLine();
		virtual void Render(Visualization3D &viewport3D, int contourIndex, int lineIndex) const;


		std::vector<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> averagePointClouds; /// The list of point cloud which are used for the average value calculation.
		std::vector<unsigned int> averagePointDensities; /// The number of points used to calculate the average value (per average value).
		std::vector<Eigen::Vector3f> averageLinePoints; /// The average values of the line depth data.
		

		double stepSize; /// The distance between the average point clouds (= 2D line length / number of line subdivisions)

	};
}

#endif